//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_WINDOW_H
#define _UX_WINDOW_H

#include <Includes.h>
#include "../Threads/IThread.h"
#include "../Input/CInput.h"

namespace Engine
{
namespace CoreSystems
{


	//
	// Window Interface
	//

	class _EXPORT_ IWindow : public CEngBaseObject, public IThread
	{
		friend class UX_OSAPI;

	protected:
		CRenderThread	*	_pRender;
		TRenderParams		_sRParams;
		TRenderInitParams	_sInitParams;
		THandles			_sHandles;
		uint				_uLastFPS,
							_uIndex;
		
	protected:
		static  void _s_SetIndex(IWindow *pWnd, uint i)		{ pWnd->_uIndex = i; }

		virtual bool _AddSharedWindow(IWindow *pWindow) = 0;

	public:
		IWindow(e_thread::type eThreadType):
			CEngBaseObject(), IThread(eThreadType), _uLastFPS(0), _pRender(nullptr), _uIndex(0)
		{}
		
		~IWindow()
		{}

		virtual bool  Init() = 0;
		virtual bool  MainLoop() = 0;
		virtual void  MakeCurrent() const = 0;
		virtual bool  Quit() = 0;
		virtual bool  Show() = 0;
		virtual bool  Hide() = 0;
		virtual bool  IsPaused() = 0;
		virtual void  AllowPause(bool bAllow) = 0;

		virtual void  AddEventListener(IWindowEventListener *pEvList, e_win_event::type eEvents) = 0;
		virtual void  RemoveEventListener(IWindowEventListener *pEvList) = 0;

		virtual void  AddUpdater(IWindowUpdater *pUpd) = 0;
		virtual void  RemoveUpdater(IWindowUpdater *pUpd) = 0;
		
		virtual void  ShowFPS(bool bShow) = 0;
		virtual bool  SetCaption(const char *pCaption) = 0;
		
		virtual bool  ChangeWindowParams(const TRenderParams &sRParams) = 0;

		virtual bool  GetSharedWindow(e_thread::type eType, IWindow *&pWindow) = 0;
		virtual bool  FreeSharedWindow(IWindow *pWindow) = 0;
		
		virtual void  SendEvent(const TWindowEvent &sEvent) = 0;

		virtual CInput *			GetInputSystems() = 0;

		const TRenderParams &		GetRenderParams()		const	{ return _sRParams; }
		const TRenderInitParams &	GetRenderInitParams()	const	{ return _sInitParams; }
		const THandles &			GetHandles()			const	{ return _sHandles; }
		uint						GetFPS()				const	{ return _uLastFPS; }
		uint						GetIndex()				const	{ return _uIndex; }
		CRenderThread *				GetRender()				const	{ return _pRender; }

		void SetRender(CRenderThread *pRen)							{ _pRender = pRen; }
	};

//-------------------------------------------------------------------

}	// CoreSystems
}	// Engine

#endif	// _UX_WINDOW_H